
import React, { Component,Fragment } from 'react';
import {withRouter} from 'react-router-dom';
//  该组件是我们自定义的导航组件,用来替换Link
class Mynav extends Component {
    render() {
        // console.log('Mynav',this);
        const text = this.props.children;  // 导航内容
        const url = this.props.to // 导航地址
        const Tag = this.props.tag? this.props.tag:'a'   // 导航设置的标签
        return (
            <>
              <Tag onClick={this.go.bind(this,url)}>{text}</Tag>
            </>
        );
    };
    go(url){
      // 跳转到指定的路径页面
    //   console.log(this);
      this.props.history.push(url)
    }
}

export default withRouter(Mynav);
